package rbac.models;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;

@Table(name = "menus")
public class Menu extends ActiveRecordBase {
	@Id
	private int id;
	@Column
	private String menuid;
	@Column
	private String name;
	@Column
	private String url;
	@Column
	private String icon;
	@Column
	private int large;
	@Column
	private int visable;
	@Column
	private int parentid;
	@Column
	private int sort;
	@Column
	private int groupid;
	@Column
	private String caption;

	// @BelongsTo(foreignKey="demoId")
	// private Demo demo;

	// public Demo getDemo() {
	// return demo;
	// }
	// public void setDemo(Demo demo) {
	// this.demo = demo;
	// }

	public int getChildCount() throws Exception {
		return (int) count(Menu.class, "parentid=?", new Object[] { id });
	}

	// public String findChildIds() throws Exception {
	// String s = "";
	// List<Integer> ids = new ArrayList<Integer>();
	// ids.add(id);
	// while(!ids.isEmpty()){
	// int id = ids.remove(0);
	// s += id + ",";
	// for(Menu item: Menu.findAll(Menu.class, "parentId=?", new Object[]{id})){
	// ids.add(item.getId());
	// }
	// }
	// if (!s.equals("")){
	// s = s.substring(0, s.length() - 1);
	// }
	// return s;
	// }
	public void setGroupid(int groupid) {
		this.groupid = groupid;
	}

	public int getGroupid() {
		return groupid;
	}

	public void setLarge(int large) {
		this.large = large;
	}

	public int getLarge() {
		return large;
	}
	
	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public String getCaption() {
		return caption;
	}

	public void setMenuid(String menuid) {
		this.menuid = menuid;
	}

	public String getMenuid() {
		return menuid;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getIcon() {
		return icon;
	}
	
	public void setUrl(String url) {
		this.url = url;
	}

	public String getUrl() {
		return url;
	}

	public void setVisable(int visable) {
		this.visable = visable;
	}

	public int getVisable() {
		return visable;
	}

	public void setParentid(int parentid) {
		this.parentid = parentid;
	}

	public int getParentid() {
		return parentid;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	public int getSort() {
		return sort;
	}

}
